package org.zzz.hepotaiya.util;

import java.util.ResourceBundle;

import org.apache.commons.lang.StringUtils;

public class ResourceUtil {
	private static ResourceBundle bundle;
	
	private static final String bundleName = "batchy";
	
	private static final String searchString = "?";
	
	static {
		bundle = ResourceBundle.getBundle(bundleName);
	}
	
	public static String getString(String key, Object... args) {
		String text = bundle.getString(key);
		if (null == args) {
			return StringUtils.replaceOnce(text, searchString, "null");
		}
		for (Object replacement : args) {
			if (null == replacement) {
				text = StringUtils.replaceOnce(text, searchString, "null");
				continue;
			}
			text = StringUtils.replaceOnce(text, searchString, replacement.toString());
		}
		return text;
	}
}
